# Contributor: Dennis Krupenik <dennis@krupenik.com>
# Maintainer: Dennis Krupenik <dennis@krupenik.com>
pkgname=opencl-clang
pkgver=12.0.0
pkgrel=1
pkgdesc="opencl-clang is a thin wrapper library around clang"
url="https://github.com/intel/opencl-clang"
arch="x86_64"
license="NCSA"
depends_dev="spirv-llvm-translator-dev"
_llvmver=12
makedepends="$depends_dev clang-static cmake llvm-static~$_llvmver"
subpackages="$pkgname-dev"
source="https://github.com/intel/opencl-clang/archive/v$pkgver/$pkgname-$pkgver.tar.gz
	cl_headers-clang-include.patch
	"
options="!check"  # no check in upstream

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None \
		-DBUILD_SHARED_LIBS=True \
		-DPREFERRED_LLVM_VERSION="$_llvmver" \
		$CMAKE_CROSSOPTS .
	make -C build
}

package() {
	make -C build DESTDIR="$pkgdir" install
}

sha512sums="
7fa05480b10be97dd784b8fb7579a2471cf3a904facd9949a980602085515bb3d42a042c74db80381771ad18f78bed2efdcb09538a865ac4a600d6190b8f9c31  opencl-clang-12.0.0.tar.gz
87cbb5e5dfe289971d4aa979faae57cbd2b994f1543e819be07626990388b40c70610f437f0a3825c6aa2361cc88827eae4f15e3fedc979b64afb6f7e72f9a6e  cl_headers-clang-include.patch
"
